//
//  PBCountDetailController.m
//  PBHomeDemo
//
//  Created by Playboy on 2018/3/16.
//  Copyright © 2018年 tmkj. All rights reserved.
//

#import "PBCountDetailController.h"
#import "PBPayNowController.h"

@interface PBCountDetailController ()
@property (strong, nonatomic) IBOutlet UILabel *timeLabel;
@property (strong, nonatomic) IBOutlet UIImageView *coverImageView;
@property (strong, nonatomic) IBOutlet UILabel *nameLabel;
@property (strong, nonatomic) IBOutlet UILabel *desLabel;
@property (strong, nonatomic) IBOutlet UILabel *priceLabel;
@property (strong, nonatomic) IBOutlet UILabel *rentLabel;
@property (strong, nonatomic) IBOutlet UILabel *rentPriceLabel;
@property (strong, nonatomic) IBOutlet UILabel *yaLabel;
@property (strong, nonatomic) IBOutlet UILabel *sumLabel;
@property (strong, nonatomic) IBOutlet UILabel *sumAllLabel;
@property (strong, nonatomic) IBOutlet UIButton *payButton;

@end

@implementation PBCountDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self configure];
}
- (void)configure {
    [self configureView];
    [self configureData];
}

- (void)configureView {
    self.timeLabel.text = @"应缴费日期";
    [self.coverImageView sd_setImageWithURL:[NSURL URLWithString:self.model.cover] placeholderImage:nil];
    self.nameLabel.text = self.model.name;
    self.desLabel.text = self.model.name;
    self.priceLabel.text = [NSString stringWithFormat:@"%@元/月",self.model.rent];
    self.rentLabel.text = [NSString stringWithFormat:@"租金(%@元/月)",self.model.rent];
    self.rentPriceLabel.text = [NSString stringWithFormat:@"¥%@元",self.model.rent];
    self.yaLabel.text = [NSString stringWithFormat:@"¥%@元",self.model.rent];
    self.sumLabel.text = [NSString stringWithFormat:@"¥%@元",self.payModel.price];
    self.sumAllLabel.text = [NSString stringWithFormat:@"¥%@元",self.payModel.price];
    [self.payButton setTitle:[NSString stringWithFormat:@"去支付¥%@",self.payModel.price] forState:UIControlStateNormal];
}
- (void)configureData {
    
}


- (IBAction)payNowButtonClick:(id)sender {
    // 创建订单
    [self showHud];
    NSDictionary *param = @{@"itemId":[NSString stringWithFormat:@"%zd",self.payModel.ID]};
    [TMNetwork requestPostWithParam:param url:@"/order/create" callback:^(TMBaseReqModel *model) {
        [self hideHud];
        if (model.code == 200) {
            PBPayNowController *vc = [[PBPayNowController alloc] init];
            vc.payModel = self.payModel;
            vc.code = model.data;
            [self.navigationController pushViewController:vc animated:YES];
        }else {
            [self showHint:model.message];
        }
    }];
}

#pragma mark - super
- (void)resetNavigationBarItems {
    [super resetNavigationBarItems];
    self.title = @"账单详情";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
